package com.example.test.多线程;

/**
 * @author 晓果冻
 * @version 1.0
 * @date 2022/5/26 15:47
 */
public class ThreadDemo extends Thread{
    @Override
    public void run(){
        System.out.println(Thread.currentThread().getName()+"我是子线程");
        try {
            Thread.sleep(3000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println(Thread.currentThread().getName()+"子线程阻塞完毕");
    }

    public static void main(String[] args) {
        //启动线程 调佣start方法而不是run方法
        // new ThreadDemo().run();
        System.out.println(Thread.currentThread().getName());
        new ThreadDemo().start();
        new ThreadDemo().start();
        System.out.println("主线程执行完毕");
    }
}
